{% extends 'TopxiaWebBundle::bootstrap-modal-layout.html.twig' %}
{% import "TopxiaWebBundle::macro.html.twig" as web_macro %}
{% set modalSize = 'large' %}

{% block title %}我的分享历史{% endblock %}

{% set side_nav = 'material-lib' %}
{% set parentId = parentId | default(null)%}

{% block body %}
<script type="text/javascript">
$("#target-teachers-input").select2({
    multiple: true,
    data:[
        {% for contact in allTeachers %}
            {% if contact.id != currentUserId %}
                {id: '{{ contact.id }}', text: '{{ contact.nickname }}'},
            {% endif %}
        {% endfor %}
        ]
});

</script>
<div id="share-history-table-container" class="materials-modal-body">
  <form id="share-materials-form" class="form-horizontal" method="post" action="{{ path('material_lib_save_sharing') }}">
    <div class="form-group">
      <label class="control-label col-md-3" for="login_username">分享教学资料给</label>
      <div class="controls col-md-8">
        <div class="select2-container select2-container-multi width-full"
                id="target-teachers-input" placeholder="输入用户名"></div>
        <div class="help-block"></div>
      </div>
    </div>
  </form>
  <div class="nav-btn-tab">
    <ul class="nav nav-tabs" role="tablist">
      <li  data-target="#user-tab" class="active">
        <a href="javascript:;"data-url="{{ path('material_lib_my_sharing_users') }}" class="active js-share-users">分享用户</a>
      </li>
      <li  data-target="#detail-tab">
        <a href="javascript:;" class="js-share-history-detail" data-url="{{ path('material_lib_my_sharing_detail') }}">历史记录</a>
      </li>
    </ul>
  </div>
  <table class="table table-hover table-striped" id="share-history-table">
    <tbody class="share-show-users-tbody">
      <div>
        <tr>
          <th width="40%"class="text-center">昵称</th>
          <th width="40%" class="text-center">时间</th>
          <th width="20%"class="text-center">操作</th>
        </tr>
        {% for history in shareHistories %}
        <tr class="share-history-record" data-role="item">
          <td class="text-center">
            将资料分享给 {{ (targetUsers[history['targetUserId']])['nickname'] }} 老师。
          </td>
          <td class="text-center">{{ history['updatedTime']|date('Y-n-d H:i') }}</td>
          <td class="text-center">
            {% if history['isActive'] == '1' %}
            <div class="pull-right">
              <a data-url="{{ path('material_lib_cancel_sharing') }}" targetUserId="{{ history['targetUserId'] }}" class="btn btn-default btn-sm cancel-share-btn">取消分享</a>
            </div>
            {% endif %}
          </td>
        </tr>
        {% else %}
        <tr class="empty">
          <td colspan="3">无资料分享记录</td>
        </tr>
        {% endfor %}
      </div>
    </tbody>
  </table>
</div>
<script>app.load('materiallibbundle/controller/material-lib/share-history')</script>
<script>app.load('materiallibbundle/controller/material-lib/teachers')</script>


{% endblock %}
{% block footer %}
<button id="share-materials-form-submit" type="submit"
    class="btn btn-primary pull-right" data-toggle="form-submit"
    data-target="#share-materials-form" data-submiting-text="正在保存...">保存</button>
<button type="button" class="btn btn-link pull-right"
    data-dismiss="modal">取消</button>
{% endblock %}
